Automatic Image Orientation and Straightening through Image Analysis

ABSTRACT

Systems, methods, and computer readable media for adjusting the orientation of an image frame and a scene depicted in the image frame are described. In general, techniques are disclosed for analyzing an image with one or more feature detectors to identify features in the image. An alignment or position associated with one or more features identified in the image may be used to determine a proper orientation for the image frame. The image can then be rotated to the proper orientation. It may also be determined if a scene depicted in the image is properly aligned in the rotated image orientation. If not, alignment information associated with the identified features may be utilized to straighten the depicted scene.

BACKGROUND

This disclosure relates generally to adjusting the orientation of animage and straightening the scene displayed in the image. Moreparticularly, but not by way of limitation, this disclosure relates tothe use of information obtained from the analysis of an image to performthe orientation and straightening operations.

Digital images obtained with an image capture device are often storedwith an improper orientation. For example, a user may intentionallyrotate an image capture device to obtain an image having a portraitorientation but the device may store all images with a landscapeorientation. A subsequent attempt to view or edit the image (on theimage capture or another device) may therefore require a manualoperation to orient the image properly. As used herein, the properorientation of an image refers to the orientation of the image frame inwhich the image scene is depicted in the manner closest to the scene'sactual orientation. Typically, an image frame may be oriented accordingto one of four cardinal orientations (i.e., 0°, 90°, 180°, 270°). Whilethe process of manually adjusting the orientation of a single image is arelatively simple operation, it may be common for a typical user tocapture hundreds or thousands of images within a short amount of time.The process of inspecting and adjusting the orientation of each imagemay be a time-consuming and tedious operation.

Moreover, even after the image is adjusted to its proper orientation,the image scene may not be properly aligned. For example, objects havinga vertical alignment (e.g., buildings, people, etc.) may have anon-vertical alignment in the captured image. Therefore, in addition toadjusting the orientation of an image, a user may need to manuallystraighten the image scene. This process is more complicated than theadjustment of an image's orientation and it may be difficult for theuser to achieve a precise adjustment. It would be desirable to automatethese time-consuming and difficult image orientation and straighteningoperations.

SUMMARY

In one embodiment, a method to receive an image, select one or morefeature detectors, and analyze the received image with the one or morefeature detectors is described. Based on the analysis of the image, animage orientation may be determined. The determination of the imageorientation may be based on an in-plane rotational difference between atypical alignment or position of one or more identified features and thealignment or position of the identified features in the received image.The method may further include determining a rotational offset of ascene depicted in the image at the determined orientation and rotatingthe depicted scene to obtain a straightened image. The adjusted imagemay be saved in a memory. The method may be embodied in program code andstored on a non-transitory medium. The stored program code may beexecuted by a programmable control device that is part of, or controls,an image capture device.

In another embodiment, a method for receiving a first image obtainedwith an image capture device and including positional information thatdescribes an orientation of the image capture device when the firstimage was obtained is described. The first image may be analyzed withone or more feature detectors to identify one or more features in theimage having an in-plane rotational variance with respect to a knowntypical alignment and an orientation of the first image may be adjustedbased on the analysis. A second image obtained with the image capturedevice and including positional information that describes anorientation of the image capture device when the second image wasobtained may then be received. If it is determined that a change in theorientation of the image capture device during the interval between thecapture of the first and second images is less than a threshold value,an orientation of the second image may be adjusted according to theadjusted orientation of the first image. The adjusted first and secondimages may be saved in a memory. The method may be embodied in programcode and stored on a non-transitory medium. The stored program code maybe executed by a programmable control device that is part of, orcontrols, the image capture device.

In another embodiment, a method to receive an image having a particularorientation and depicting a scene is described. The received image maybe analyzed with one or more feature detectors to identify featureswithin the depicted scene. A feature offset that represents the in-planerotational difference between an expected feature alignment and anobserved feature alignment in the image may be determined for eachidentified feature. A scene offset may be calculated from the featureoffsets and the depicted scene may be rotated based on the scene offset.The method may be embodied in program code and stored on anon-transitory medium. The stored program code may be executed by aprogrammable control device that is part of, or controls, an imagecapture device.

BRIEF DESCRIPTION OF THE DRAWINGS

FIGS. 1A through 1D illustrate example feature detectors that may beutilized in accordance with one embodiment of the image orientation andstraightening operations described herein.

FIG. 2 is a flowchart that illustrates a ranked feature detector imageorientation operation in accordance with one embodiment.

FIG. 3 is a flowchart that illustrates a multiple feature detector imageorientation operation in accordance with one embodiment.

FIGS. 4A through 4C graphically illustrate image orientation operationsin accordance with various embodiments.

FIG. 5 is a flowchart that illustrates an image straightening operationin accordance with one embodiment.

FIG. 6 graphically illustrates an image straightening operation inaccordance with one embodiment.

FIG. 7 is a flowchart that illustrates the linkage of images obtained bythe same image capture device for purposes of image orientation andstraightening operations.

FIG. 8 is a block diagram for an illustrative electronic device inaccordance with one embodiment.

DETAILED DESCRIPTION

This disclosure pertains to systems, methods, and computer readablemedia to automatically modify the orientation of an image based on ananalysis of the image. In general, techniques are disclosed foranalyzing an image with one or more feature detectors, identifying anorientation and/or position for detected features, and automaticallyadjusting the orientation of the image frame and the depicted imagescene based on the orientations and positions of the detected features.

In the following description, for purposes of explanation, numerousspecific details are set forth in order to provide a thoroughunderstanding of the inventive concept. As part of this description,some of this disclosure's drawings represent structures and devices inblock diagram form in order to avoid obscuring the invention. In theinterest of clarity, not all features of an actual implementation aredescribed in this specification. Moreover, the language used in thisdisclosure has been principally selected for readability andinstructional purposes, and may not have been selected to delineate orcircumscribe the inventive subject matter, resort to the claims beingnecessary to determine such inventive subject matter. Reference in thisdisclosure to “one embodiment” or to “an embodiment” means that aparticular feature, structure, or characteristic described in connectionwith the embodiment is included in at least one embodiment of theinvention, and multiple references to “one embodiment” or “anembodiment” should not be understood as necessarily all referring to thesame embodiment.

It will be appreciated that in the development of any actualimplementation (as in any development project), numerous decisions mustbe made to achieve the developers' specific goals (e.g., compliance withsystem- and business-related constraints), and that these goals willvary from one implementation to another. It will also be appreciatedthat such development efforts might be complex and time-consuming, butwould nevertheless be a routine undertaking for those of ordinary skillin the art of image processing having the benefit of this disclosure.

Referring to FIG. 1, several example feature detectors that may beutilized in accordance with the image orientation and straighteningoperations described herein are illustrated. An image orientationoperation refers to the rotation of an image frame to a specifiedorientation. In general, the image orientation operation is directed tothe rotation of an image frame to one of the cardinal orientations(i.e., 0°, 90°, 180°, 270°), but rotation of the image frame to otherorientations (e.g., 25°, 95°, 135°, 200°, etc.) may also be performed.Image straightening operations, on the other hand, are used herein todescribe the more precise angular adjustment of the photographed scenein an image such that the horizontal/vertical directions in the sceneare aligned with the horizontal/vertical directions of the image.Therefore, image orientation refers to the in-plane rotation of an imageframe (i.e., the entire image) whereas image straightening refers to thein-plane rotation of a photographed scene with respect to the image.

Referring first to FIG. 1A, a face detector may be utilized to detectone or more faces in image 100. The detection of a face in an image maybe based on the application of one or more classifiers to detectcharacteristic colors, textures, shapes, and other characteristic facialfeatures in the image (e.g., features associated with eyes, noses, andmouths). The various classifiers may be applied to different portions ofimage 100 and may have different sizes and different angular alignments.In this way, a feature detector may be more likely to detect a face thatis rotated about the face-observer axis (in-plane rotation) or about avertical or horizontal axis with respect to the image (out-of-planerotation) as opposed to only detecting forward-looking faces.Application of the various classifiers to the different portions ofimage 100 may result in several candidate regions 105 that areidentified as a match for the particular classifier. Each candidateregion 105 may have a particular alignment (e.g., an angular alignmentwith respect to the image) and a classifier confidence (e.g., alikelihood that the candidate region contains the properties associatedwith the particular classifier). As illustrated in FIG. 1A, candidateregions 105 may converge in one or more portions of image 100 thatcontain a face. As is further illustrated, the overlapping candidateregions (and their associated confidence levels) may be combined to forma detected feature region 110, having its own associated size,alignment, and confidence metric. Although FIG. 1A illustrates an imagethat contains a single face, it will be understood that the appliedclassifiers may result in multiple areas of overlapping candidateregions that result in multiple detected feature regions (each having anassociated size, alignment, and confidence metric) in an image thatcontains multiple faces. The alignment of detected feature region 110may be described by feature alignment vector 115. Although FIG. 1Aillustrates detected feature region 110 as having a vertical alignment,it will be understood that a detected feature region may have analignment that is rotated with respect to the image (e.g., where asubject in an image is tilting their head to the side). As will bedescribed in greater detail below, feature alignment vector 115 may beutilized to adjust the orientation of image 100 and straighten thedepicted scene.

Referring to FIG. 1B, a person detector may work in a similar manner tothe face detector described above. Like the face detector, a persondetector may utilize multiple classifiers applied to different portionsof image 120 to identify people in image 120. For example, a persondetector may be based on a collection of classifiers that identify partsof people (e.g., arms, torso, head, clothing patterns, etc.) based oncolor, texture, shape, relative location with respect to other detectedpeople parts, etc. Like the classifiers utilized to detect a face, themultiple person (or person part) classifiers may be applied to differentportions of image 120 having different sizes and different angularalignments and may identify candidate regions 125 having associatedsizes, alignments, and confidence metrics. For purposes of clarity, notall of the candidate regions 125 have been labeled. Overlappingcandidate regions might then be utilized to derive a detected featureregion 130, having its own size, alignment, and confidence metric. Asillustrated in FIG. 1B, the overlapping candidate regions 125 may resultin the identification of multiple detected feature regions 130 withinimage 120. The alignment of each detected feature region 130 may bedescribed by feature alignment vector 135. Although face and persondetectors have been described in terms of multiple classifiersgenerating a composite detected feature region, it should be noted thatthe image orientation and straightening method described herein mightalso utilize detections based on individual classifiers in order toadjust the orientation of an image and straighten the depicted scene.Moreover, orientation and straightening operations are not limited toface or person detectors. Any object detector configured to identify anobject having a principal orientation can be used (e.g., trees,buildings, cars, etc.).

Referring to FIG. 1C, example image gradient map 140 of image 100 isillustrated. In one embodiment, the image orientation and straighteningoperations described below may take advantage of information that can beextracted from the evaluation of image gradients across an image. As isknown by those of skill in the art, image gradient vectors 145 mayrepresent the magnitude and direction of the change in image intensityat each point in image 100. It has been found through extensiveevaluation and refinement that image gradient map 140 information may beused to perform image alignment operations. For example, it has beenfound that image gradient map 140 may be used to provide information asto the location of light source 150. Because brighter areas of an image(such as light source 150) may typically be expected to be located atthe top of an image with darker areas (such as shadows) located towardsthe bottom of an image, the image gradient direction may provideinformation as to the proper orientation of an image (and straighteningof the depicted scene). Although FIG. 1C illustrates an image gradientmap and the utilization of image gradients themselves have beendescribed, histograms of image gradients over local areas of an imageprovide valuable information in terms of the orientation andstraightening operations. In addition, local binary patterns (thatcompute pixel differences in a predefined pattern) are good indicatorsof the light source direction.

Image gradients might also be useful in identifying edges of objectswithin image 100 where the image intensity changes sharply. In imagegradient map 140, for example, the approximate location of object 155(the person) and object 160 (the tree) may be identifiable based on ananalysis of image gradients. The approximate location of these objectscan provide information as to the proper orientation of the image (andstraightening of the depicted scene). Image gradient edge detectionmight also identify edges that represent long image lines. For example,in image gradient map 140, image gradients may identify image line 165that extends across image 100. Long image lines such as horizon 165 inimage 100 may also be useful in determining the proper orientation of animage. Like the face and person detectors described above, featuresidentified based on an analysis of image gradients may be associatedwith a particular alignment and confidence metric. Accordingly, featurealignment information may allow for the adjustment of the orientation ofan image and the straightening of the photographed scene.

Referring to FIG. 1D, a scene detector may identify a particular type ofscene in image 100. In the illustrated embodiment, a sky detector mayidentify area 170 of image 100 as possessing certain characteristics ofa sky. Area 170 may be detected based on color and/or texture propertiesthat are representative of a sky, limited image gradient, and/or otherproperties that are characteristic of the sky.

Because a sky typically appears at the top of an image, the detection ofan area having a high likelihood of being a sky may be utilized toadjust the orientation of the image. Although FIG. 1D illustrates a skydetector, other scene detectors such as building detectors, roaddetectors, grass detectors, etc. may identify scenes within an image ina similar manner. Accordingly, various types of scene detectors may beuseful in determining the proper orientation of an image and alignmentof the photographed scene.

Although multiple feature detectors have been described with respect toFIGS. 1A-1D, in light of the present disclosure it will be recognizedthat other types of feature detectors might also provide informationthat can be used to adjust the orientation of an image and straightenthe image's scene. For example, detectors that identify objects such ascars, bikes, signs, text, etc. may provide useful information. As willbe described in greater detail below, each detected feature may beassociated with a feature alignment and confidence metric that enableimage orientation and scene straightening operations in accordance withthis disclosure.

Referring to FIG. 2, image orientation operation 200 may be utilized toadjust an image's orientation and may begin with the receipt of an image(block 205). As operation 200 may be performed on an image capturedevice or on an image editing/viewing/storage device (e.g., a deviceoperating photo management software), receiving an image may includereceiving an image that was captured by an image capture device,receiving an image transferred from an image capture device to anotherdevice, receiving an image selected for viewing or editing, etc.

After an image is received, multiple feature detectors may be rankedaccording to the order in which they should be applied to the image(block 210). In a first embodiment, it may be desired to adjust theorientation of an image as quickly as possible. Such an embodiment maybe well suited for the adjustment of image orientation on an imagecapture device in close temporal proximity to the capture of the image.For example, on platforms having limited computational capabilities(e.g., digital cameras, mobile phones, tablet computer devices) it maybe desirable to quickly adjust the orientation of an image prior tostoring the image in memory that is accessible to the device (in whichcase the orientation data may be stored in the image file or in anaccompanying metadata file). The efficiency-based orientation adjustmentembodiment may also be appropriate for the adjustment of imageorientations for a large number of images. For example, when a usertransfers a large number of images from an image capture device (ormemory associated with such device) to a computational platform on whichthe images may be edited, viewed, or stored (e.g., a personal computer,television, etc.), it may be desirable to quickly adjust the orientationof the transferred images as the images are transferred. Because theefficiency-based orientation adjustment embodiment may be directed tothe adjustment of an image orientation as quickly as possible, thedetectors may be ranked in order of computational efficiency. Forexample, a scene detector such as a sky detector may be capable ofidentifying a sky in an image more quickly than a face detector iscapable of identifying one or more faces in the same image. Although theface detector may provide greater accuracy in determining a proper imageorientation than a sky detector, the sky detector may be ranked ahead ofthe face detector for purposes of the efficiency-based orientationadjustment embodiment.

In another embodiment, it may be desirable to adjust an image'sorientation according to the accuracy of detectors as opposed to theircomputational efficiency. Such an embodiment may be suitable for theadjustment of image orientation in an environment in which computationalefficiency is not a primary concern. For example, the accuracy-basedorientation adjustment embodiment may be utilized to adjust theorientation of images in a photo management application. In accordancewith the objectives of the accuracy-based orientation adjustmentembodiment, the feature detectors may be ranked according to accuracyrather than computational efficiency. In one embodiment, the ranking offeature detectors may be based on the received image. For example, aquick analysis of the image may be performed prior to ranking featuredetectors (e.g., to identify image brightness, etc.) in order todetermine whether the image is likely to contain the type of featuresthat may allow a computationally efficient detector to make an accurateorientation determination (e.g., based on the size of the image, imagecontrast, etc.) or whether an accurate orientation determination islikely to require analysis of the image by a more accurate detector.

After the feature detectors are ranked, the image may be analyzed withthe first detector according to the detector ranking (block 215). Thefirst detector may attempt to identify its particular feature within thereceived image. For example, a sky detector may attempt to identify asky within the image. If the detector identifies its particular featurewithin the received image (the “Yes” prong of block 220), an imageorientation may be determined based on the detected feature (block 225).

In one embodiment, the determination of an image orientation accordingto a detected feature may be based on the type of feature detector. Forexample, a scene detector such as a sky detector may identify a regionwithin the received image as corresponding to the particular feature(e.g., sky). Because a scene may not have an inherent alignment, thedetected feature region may not be associated with a feature alignmentdirection. For example, while a sky detector may detect a region of animage that exhibits the properties of a sky, the detected region may nothave an inherent alignment (e.g., the “top” of the sky region may not beidentifiable). The proper image orientation based on such a detectedfeature may therefore be determined according to the position of thedetected region with respect to the image as a whole. A different typeof feature detector, on the other hand, may be associated with a featurealignment that can be utilized to determine the proper imageorientation. For example, a detected face or person may be associatedwith not only a detected feature region but also a feature alignmentvector as described above with respect to FIGS. 1A and 1B. The featurealignment vector may be utilized to determine the proper orientation ofthe image. Although a scene detector has been described for the purposesof illustrating that an image orientation might be determined based onthe position of a detected feature with respect to the image, a scenedetector may also have an associated alignment. For example, a skydetector, in addition to detecting a region that has the characteristicsof a sky, might also identify the alignment of the sky (e.g., based onan intensity gradient within the detected region).

As discussed briefly above, the determination of the proper orientationof the received image refers to the determination of the in-planerotation of the image frame. The alignment and/or position of a detectedfeature, therefore, may be utilized to determine an image orientationthat would effect a known typical alignment or position for the detectedfeature. For example, if a detected feature region associated with a skydetector occupies the left part of a received image in its currentorientation, the proper image orientation might be determined to be anorientation in which the image is rotated clockwise 90° from thereceived orientation such that the detected feature region occupies thetop part of the image in the rotated orientation. Likewise, the properimage orientation might be determined to be an orientation in which analignment associated with a detected feature region (e.g., a directioncomponent of an alignment vector) corresponds to a known typicalalignment. For example, if one or more detected feature regionsassociated with a face or person detector identify an alignment thatpoints to the left side of the received image, the proper imageorientation might be determined to be an orientation in which the imageis rotated clockwise 90° from the received orientation such that thedetected feature alignments are oriented vertically with respect to theimage in its rotated orientation. It will be understood that in oneembodiment, because the image orientation operation identifies one offour main orientations, it may not be possible (or even desirable) toobtain a feature alignment that is perfectly aligned with the typicalalignment. Thus, a feature alignment within a particular angular rangemay result in the identification of a particular image orientation. Forexample, a detected feature region associated with a face detector andhaving a feature alignment value that is rotated 82° clockwise withrespect to the vertical axis in the received image orientation mayresult in a determination that the proper image orientation is theorientation in which the image is rotated 90° counterclockwise from thereceived orientation such that the face is oriented substantiallyvertically with respect to the image in its rotated orientation. As willbe described in greater detail below, the slightly out of verticalalignment of the detected feature in the rotated orientation may eitherbe identified as proper or corrected through an image straighteningoperation in a subsequent step.

After an image orientation is determined based on a detected feature, itmay be determined if a confidence level in the determined orientationexceeds a threshold confidence value (block 230). In one embodiment, theconfidence in a determined image orientation may include measurements ofthe individual feature detector's confidence in its detection, theaccuracy of the detector, and any discrepancies in orientation based onmultiple detected feature regions. As described above with respect toFIGS. 1A-1D, a detected feature region and/or alignment may have anassociated confidence value. For example, a face detector may determinewith an 80% confidence value that a particular region having aparticular alignment in an image contains a face. As will be recognizedby those of skill in the art, this confidence value may be based on therelationship between properties of the image within the region (e.g.,color, texture, etc.) as compared to properties of “known” or “training”features upon which the detector is based. This detector confidencevalue may feed into the confidence value associated with an imageorientation determination.

The confidence value associated with an image orientation determinationmight also take into account the accuracy of the particular type ofdetector(s). For example, certain feature detectors might be moreaccurate at determining an image orientation than others. Accordingly,in one embodiment, a predetermined accuracy may be assigned to eachparticular detector. Therefore, the confidence in a determined imageorientation might be based on a predetermined detector accuracy adjustedbased on the detector's confidence in its identification of a feature inan image. By way of example, a detector having an accuracy level of 80%and a confidence level of 80% in a detected feature region may result ina confidence value of 64% in an image orientation determination based onthe detected feature. It will be recognized by those of ordinary skillin the art that other confidence algorithms might be applied.

The confidence value associated with a particular determined imageorientation might also include a factor to account for discrepanciesbased on multiple conflicting detected feature regions. Suppose, forexample, that a face detector is applied to an image that includes twochildren. If one of the children in the image is lying down and theother is sitting up, the face detector may identify two detected featureregions with associated alignment values that are approximatelyorthogonal. Although each face may be detected with a high degree ofconfidence, there can be almost no confidence in the proper orientationof the image based solely on the detected face regions. Accordingly, theconfidence value associated with a determined image orientation may bedecreased where two or more detected features suggest divergent imageorientations. The confidence value associated with the determined imageorientation may be compared with a predetermined threshold value. If theconfidence value exceeds the threshold (the “Yes” prong of block 230),the image may be rotated to the determined orientation (block 240) andstored in a memory in the rotated orientation (block 245). In oneembodiment, the image rotation operation may be capable of being“undone” by a user such that the image may be returned to its originalorientation. If it is determined that the detector did not identify itsparticular feature or that the confidence in a determined orientationdoes not exceed the threshold (the “No” prongs of blocks 220 and 230,respectively), the received image might be analyzed with the nextdetector in the list of detectors (block 235).

Referring to FIG. 3, in still another embodiment, multiple detectorimage orientation operation 300 may utilize multiple feature detectorsto determine an appropriate image orientation. Operation 300 may becapable of identifying a proper image orientation with a high degree ofaccuracy because it combines feature detection information from multipleapplied feature detectors. Operation 300 may differ from operation 200in that feature detectors may not be applied in a particular order(e.g., may not be ordered according to computational efficiency oraccuracy). In fact, application of multiple feature detectors to aparticular image may not even occur in close temporal proximity. Forexample, operation 300 may utilize information available from theprevious application of multiple feature detectors to an image in orderto identify a proper image orientation. Accordingly, operation 300differs from operation 200 in that an image orientation determination isnot made based on the application of a single feature detector. Rather,an image is analyzed with multiple feature detectors (block 305) andfeature identification information (e.g., detected feature regions,confidence values, etc.) from the multiple detectors is utilized to makean image orientation determination. The feature identificationinformation associated with each of the applied detectors may be savedas metadata associated with the received image (either part of, orseparate from, the image). In one embodiment, the multiple featuredetectors applied to an image may be a predetermined group of detectorsthat are known to combine well to determine a proper image orientation.

In one embodiment, the feature identification information associatedwith each applied feature detector may be assigned a weight. The weightapplied to each feature detector may be similar to the confidence valuesdescribed above. For example, the weight may include a predetermineddetector accuracy value, a confidence value based on the application ofthe detector to the received image, and a factor to account fordiscrepancies based on multiple conflicting detected feature regions fora single detector. The weighted feature identification information basedon the multiple feature detectors may then be aggregated (block 310) todetermine a proper orientation of the received image (block 315). In oneembodiment, an image orientation determination may be based on anaggregation of weighted image orientation estimates of the individualfeature detectors. For example, each of the multiple weighted individualimage orientation estimates (i.e., the image orientation determinationsbased on the individual detectors such as those described with respectto operation 200) may have an associated score (i.e., based on theassigned weight) and the scores may be combined to determine an imageorientation. As will be described in greater detail below, in oneembodiment, the individual image orientation estimates may includeoffset information (e.g., the difference between a typical alignment andthe measured alignment of a particular identified feature at theestimated orientation) to improve the accuracy of operation 300. Forexample, the combined offset information from the multiple detectors maybe required to fall within a certain angular range (e.g., ±5°) beforethe aggregate image orientation determination will be accepted. Theimage orientation determination based on the aggregate information maybe effected by rotating the received image to the determined orientation(block 240) and storing the image in a memory in the rotatedorientation—with, or without, “undo” information (block 245).

Although operations 200 and 300 have been described separately, it willbe understood that portions of the described operations may be combined.For example, a computationally efficient detector may be utilized tomake an initial orientation decision and a more accurate detector may beapplied thereafter to verify the orientation. Such an approach mayincrease the computational efficiency of the more accurate detector. Forexample, because it can initially be assumed that the quick detectormade the proper orientation decision, the efficiency of a more accuratedetector (such as a face detector) can be increased by ignoring otherpotential orientations in an attempt to verify the initial orientationdetermination. As such, the more accurate detector may be applied to asmaller subset of image portions (e.g., those portions having anorientation that matches the initial orientation determination). Itshould also be noted that operations 200 and 300 may operate on a lowresolution version of an image to increase operational efficiency.Moreover, the operations may run on a copy of the image in a backgroundthread or on a graphics processing unit.

Referring to FIG. 4A, an image having orientation 400 is received. Inaccordance with operation 200, a face detector may identify detectedfeature region 405 having a feature alignment vector 410. Because theface detector is associated with a “typical” vertical alignment 415, thedifference between the directional component of feature alignment vector410 and “typical” alignment 415 may result in the determination theimage should be rotated 90° clockwise to orientation 420. If aconfidence value associated with the determined orientation exceeds athreshold, the image may be rotated and saved according to orientation420.

Referring to FIG. 4B, the subject in a received image having orientation430 has a slightly rotated face with respect to the subject in thereceived image of FIG. 4A. In accordance with operation 200, a facedetector may identify detected feature region 435 having a featurealignment vector 440. Although the difference between the directionalcomponent of feature alignment vector 440 and “typical” alignment 415does not precisely correspond to one of the four main image orientations(e.g., 0°, 90°, 180°, and 270°), it may still be determined that theimage should be rotated 90° clockwise to orientation 450 because theangular difference falls within a predetermined range (e.g., 90°±15°)for that orientation. If a confidence value associated with thedetermined orientation exceeds a threshold, the image may be rotated andsaved according to orientation 450.

Referring to FIG. 4C, an image having orientation 460 is received. Aperson detector identifies detected feature regions 465A and 465B havingfeature alignment vectors 470A and 470B, respectively. A sky detectoridentifies area 480 as a detected sky region. In accordance withoperation 300, based on a combination of the differences between thedirectional components of feature alignment vectors 470A and 470B ascompared to “typical” person alignment 475, it may be determined thatthe image should be rotated 90° counter-clockwise to achieve the properorientation. It may also be determined based on the position of area 480that the image should be rotated 90° counter-clockwise to achieve theproper orientation of the photographed scene. The individual detectorimage orientation estimates may be weighted according to detectoraccuracy, confidence, and detected feature discrepancies and combined toform an aggregate image orientation determination. As noted above, eachindividual detector image orientation determination may be associatedwith an orientation offset. For example, because feature alignmentvectors 470A and 470B have directional components (in orientation 460)that result in an in-plane rotational variance with respect to “typical”alignment 475 of less than 90°, the individual image orientationestimate based on the person detector may be a 90° counter-clockwiserotation having an associated 3° offset (to account for the differencebetween the directional component of the feature alignment vectors andthe “typical” alignment in the rotated orientation). Because each of theperson detector and sky detector agree on an image orientation, it maybe determined that the image should be rotated to orientation 485 if theweighted combination of the individual orientation offsets is within apredetermined range (e.g., ±5°). In one embodiment, the image may berotated to an orientation only if the individual image orientationestimates agree unanimously. In another embodiment, the image may berotated to a specified orientation if a certain percentage of theindividual image orientation estimates agree on the orientation.

Referring to FIG. 5, image straightening operation 500 may adjust thephotographed scene such that it is properly aligned at the selectedimage orientation. Straightening operation 500 may begin with thedetermination of a proper image orientation as described above (block505). In one embodiment, the selected image orientation may bedetermined based on one of automatic orientation operations 200 or 300.In another embodiment, image orientation may be selected manually, suchas, for example, by a user editing the image with a photo managementapplication. After an image orientation is selected, the image may beanalyzed with one or more feature detectors (block 510). Each featuredetector may identify a feature offset at the selected image orientation(block 515). As described briefly above with respect to the imageorientation operation, a feature offset may refer to the angulardifference between an identified feature's alignment and an expectedalignment at the selected image orientation. Feature offsets may fallinto two categories. A first category of proper feature offsets (e.g.,an offset based on a subject's tilted head) should not be corrected bythe straightening operation and a second category of improper offsets(e.g., an offset associated with the orientation of an image capturedevice at an angle other than one of the four main orientations) shouldbe corrected by the straightening operation.

Because it may be difficult to distinguish between proper and improperoffsets, in a typical embodiment, straightening operation 500 may bebased on feature offsets from multiple feature detectors in order toaccurately straighten the photographed scene. Therefore, if imageorientation (block 505) was performed manually or based on operation200, it may be necessary to subject the image to analysis by one or moreadditional feature detectors. However, the information associated with aparticular feature detector utilized as part of an automatic imageorientation operation (such as operations 200 and 300) may be saved withthe image as image metadata. This information may include the featureoffset. For example, if it is determined during an automatic imageorientation operation utilizing a face detector that the differencebetween a detected face's alignment and a “typical” alignment is 87° andthat the image should be rotated 90° clockwise, the image may be savedaccording to the rotated orientation and may have associated metadataindicative of a face detector feature offset of 3°. Accordingly, it maynot be necessary to analyze an image with the same feature detector thatwas previously used to make an image orientation determination.

The feature offset information of the one or more applied featuredetectors may be aggregated according to a straightening operation todetermine an aggregate scene offset (block 520). Like the orientationdeterminations described above, each feature offset may be associatedwith a confidence value. The accuracy component of a confidence valuefor a particular detector may be different for an orientation operationas compared to a straightening operation. For example, while a facedetector may be highly accurate for determining an image orientation,because a feature offset based on a detected face may commonly beassociated with a proper feature offset, its accuracy component withrespect to a straightening operation may be less than its accuracycomponent for an orientation operation.

In one embodiment, the straightening operation may compute a weightedaverage (e.g., incorporating the feature offset confidence values) ofthe individual feature offsets. In one embodiment, individual featureoffset outliers (e.g., feature offsets having more than a certainpercentage of a calculated standard deviation away from the weightedaverage) may not be included in the computation of the aggregate sceneoffset. In another embodiment, multiple straightening operations may beapplied (e.g., inclusive of, exclusive of, and weighting differentlycertain feature offsets) and multiple straightened images based on themultiple calculated scene offsets may be presented to a user forselection of the most appropriate result.

After a scene offset is determined, the photographed scene may berotated by an angle equal to the calculated scene offset (block 525).The image may optionally be cropped such that the straightened imagemaintains the same aspect ratio as the original image (block 530) andthe straightened image may be saved in a memory (block 535). Like theimage orientation operation, metadata may be retained such that thestraightening operation may be “undone” and the original imagerecovered.

Referring to FIG. 6, straightening operation 500 is illustrated withrespect to example image 600. As illustrated, image 600 has been rotatedto the proper one of the four main orientations (i.e., the scene isgenerally illustrated in the proper manner). However, the photographedscene in image 600 is skewed with respect to the proper presentation. Inaccordance with image straightening operation 500, image 600 may beanalyzed by multiple feature detectors. In the illustrated embodiment,for example, a face detector may identify detected feature region 605and a horizon detector may identify detected feature region 615. Thesedetected feature regions may be associated with alignments that differfrom “typical” alignments for the respective features as illustrated byoffsets 610 and 620 respectively. The feature offsets may be assignedweights and aggregated to determine scene offset 625 as described above.It will be understood that image 600 may be analyzed with more (orfewer) than two feature detectors in which case additional featureoffsets may be identified and may therefore contribute to the calculatedaggregate scene offset. The photographed scene may then be rotated(maintaining the existing image orientation) to account for scene offset625, and the resulting image cropped and saved in a memory asstraightened image 630.

Referring to FIG. 7, operation 700 may incorporate metadata associatedwith a received image to improve the efficiency and accuracy of theorientation and straightening operations. In the same manner asdescribed above, a first image may be received (block 705) andorientation and straightening operations may be performed on the image(block 710). When a second image is subsequently received (block 715),it may be determined if the second image was captured by the same imagecapture device as the first image and whether the second image wascaptured in close temporal proximity to the first image (block 720).

Each of the first image and second image may include metadata thatprovides information about the image capture device used to obtain theimage as well as a time the image was obtained, thereby allowing adetermination of whether the first and second images were obtained withthe same image capture device at approximately the same time. The imagemetadata may also include rotational information obtained frompositional sensors (such as gyroscopes and/or accelerometers) thatprovide information regarding the orientation of the image capturedevice at the time each image was obtained. This rotational informationmight include readings for three rotational axes (one of which may bethe camera rotation axis). If it is determined that the first and secondimages were obtained by the same image capture device in close temporalproximity (the “Yes” prong of block 720), the rotational informationincluded in the metadata for the first and second images may be utilizedto determine whether a change in the orientation of the image capturedevice during the interval between the capture of the first and secondimages exceeds a threshold (block 725). In one embodiment, the thresholdmay define a particular angular rotation about the camera rotation axis(i.e., the image-observer access that contributes to the in-planerotation of the image). If the first and second images were not capturedby the same image capture device at approximately the same time or ifthe rotational information indicates a change in orientation of theimage capture device that exceeds the threshold (the “No” and “Yes”prongs of blocks 720 and 725 respectively), the orientation and/orstraightening operations may be performed independently on the secondimage (block 735). If, however, it is determined that the rotationalinformation does not indicate a change in orientation of the imagecapture device that exceeds the threshold (i.e., the rotationalinformation indicates a small change in the orientation of the imagecapture device between the capture of the first and second images) (the“No” prong of block 725), the first and second images may be linked forpurposes of the orientation and straightening operations (block 730).That is, the orientation and/or straightening determinations for thefirst image may influence the orientation and/or straighteningdeterminations for the second image.

The linkage of two images captured by the same image capture device mayincrease the efficiency of the orientation operation. For example, inone embodiment, if the interval between the capture of the first andsecond images is of a short duration and there is a small change in theorientation of the image capture device, the orientation adjustmentapplied to the first image may simply be applied to the second imagesuch that no further analysis of the second image is necessary. Inanother embodiment, the orientation operation may utilize theorientation determination for the first image as an initial orientationdetermination for the second image such that orientation-specificfeature detectors (e.g., face detectors) may be applied to a smallersubset of image portions (e.g., those portions having an orientationthat matches the initial orientation determination) based on the initialorientation determination.

The linkage of the first and second images may also improve the accuracyof the orientation operation. For example, if a parent takes a firstphotograph of a child running around at a park, the image orientationoperation might rotate the image frame to an orientation in which thechild is positioned upright. If the orientation operation then receivesa second image of another child hanging upside down (captured soon afterthe first image), the orientation operation (e.g., based on the analysisof the second image with a face detector) may incorrectly determine thatthe image should be rotated to the orientation in which the child ispositioned upright. However, based on the orientation determination forthe first image in conjunction with rotational information thatindicates that very little camera rotation occurred between the firstand second images, the orientation operation may determine that thechild in the second image must be upside down.

While the rotational information provided by an image capture device mayallow the orientation operation to accurately determine that nosignificant rotational change (e.g., a 90° change between primaryorientations) occurred during the interval between the capture of thefirst and second images, the information might be less reliable in termsof the precise angular adjustments of the image straightening operation.Nonetheless, in the same manner that the rotational information may beutilized to link images for purposes of the orientation operation, itmight also be utilized to link images for purposes of the straighteningoperation. In one embodiment, to account for potential drift in therotational information provided by an image capture device over time, adamping factor may be included in determining the weight to be accordedto a calculated scene offset for a first image with respect to a sceneoffset for a second image such that the effect of the prior scene offseton the subsequent scene offset decreases as the time interval betweenthe capture of the first image and the second image increases.

Referring to FIG. 8, a simplified functional block diagram ofillustrative electronic device 800 is shown according to one embodiment.Electronic device 800 may include processor 805, display 810, userinterface 815, graphics hardware 820, device sensors 825 (e.g.,proximity sensor/ambient light sensor, accelerometer and/or gyroscope),microphone 830, audio codec(s) 835, speaker(s) 840, communicationscircuitry 845, digital image capture unit 850, video codec(s) 855,memory 860, storage 865, and communications bus 870. Electronic device800 may be, for example, a personal digital assistant (PDA), personalmusic player, mobile telephone, digital camera, notebook, laptop or atablet computer, desktop computer, or server computer. Moreparticularly, the above-described processes may be performed on a devicethat takes the form of device 800.

Processor 805 may execute instructions necessary to carry out or controlthe operation of many functions performed by device 800. Processor 805may, for instance, drive display 810 and receive user input from userinterface 815. User interface 815 can take a variety of forms, such as abutton, keypad, dial, a click wheel, keyboard, display screen and/or atouch screen. Processor 805 may also, for example, be a system-on-chipsuch as those found in mobile devices and include a dedicated graphicsprocessing unit (GPU). Processor 805 may be based on reducedinstruction-set computer (RISC) or complex instruction-set computer(CISC) architectures or any other suitable architecture and may includeone or more processing cores. Graphics hardware 820 may be specialpurpose computational hardware for processing graphics and/or assistingprocessor 805 to process graphics information. In one embodiment,graphics hardware 820 may include a programmable graphics processingunit (GPU).

Sensor and camera circuitry 850 may capture still and video images thatmay be processed, at least in part, by video codec(s) 855 and/orprocessor 805 and/or graphics hardware 820, and/or a dedicated imageprocessing unit incorporated within circuitry 850. Images so capturedmay be stored in memory 860 and/or storage 865. Memory 860 may includeone or more different types of media used by processor 805 and graphicshardware 820 to perform device functions. For example, memory 860 mayinclude memory cache, read-only memory (ROM), and/or random accessmemory (RAM). Storage 865 may store media (e.g., audio, image and videofiles), computer program instructions or software (such as photomanagement software), preference information, device profileinformation, and any other suitable data. Storage 865 may include one ormore non-transitory storage mediums including, for example, magneticdisks (fixed, floppy, and removable) and tape, optical media such asCD-ROMs and digital video disks (DVDs), and semiconductor memory devicessuch as Electrically Programmable Read-Only Memory (EPROM), andElectrically Erasable Programmable Read-Only Memory (EEPROM). Memory 860and storage 865 may be used to tangibly retain computer programinstructions or code organized into one or more modules and written inany desired computer programming language. When executed by, forexample, processor 805 such computer program code may implement one ormore of the methods described herein.

It is to be understood that the above description is intended to beillustrative, and not restrictive. The material has been presented toenable any person skilled in the art to make and use the inventiveconcepts described herein, and is provided in the context of particularembodiments, variations of which will be readily apparent to thoseskilled in the art (e.g., some of the disclosed embodiments may be usedin combination with each other). Many other embodiments will be apparentto those of skill in the art upon reviewing the above description. Thescope of the invention therefore should be determined with reference tothe appended claims, along with the full scope of equivalents to whichsuch claims are entitled. In the appended claims, the terms “including”and “in which” are used as the plain-English equivalents of therespective terms “comprising” and “wherein.”

1. A non-transitory program storage device, readable by a processor andcomprising instructions stored thereon to cause the processor to:receive an image; determine an orientation for the received image based,at least in part, on one or more identified features in the receivedimage; identify an alignment of the one or more identified features inthe received image; determine an offset between a known typicalalignment and the identified alignment for each of the one or moreidentified features at the determined orientation; rotate the receivedimage based, at least in part, on the determined offset to generate astraightened image; and save the straightened image in a memory.
 2. Thenon-transitory program storage device of claim 1, further comprisinginstructions to cause the processor to analyze the received image withone or more feature detectors in a predetermined order.
 3. Thenon-transitory program storage device of claim 2, wherein thepredetermined order comprises an order based on feature detectorcomputational efficiency.
 4. The non-transitory program storage deviceof claim 2, wherein the predetermined order comprises an order based onfeature detector accuracy.
 5. The non-transitory program storage deviceof claim 1, wherein the instructions to cause the processor to determinean orientation for the received image further comprise instructions tocause the processor to assign an orientation confidence value to thedetermined orientation.
 6. The non-transitory program storage device ofclaim 5, wherein the orientation confidence value comprises a detectedfeature confidence value associated with each of the one or moreidentified features.
 7. The non-transitory program storage device ofclaim 5, wherein the orientation confidence value comprises apredetermined accuracy value associated with the one or more featuredetectors.
 8. The non-transitory program storage device of claim 1,further comprising instructions to cause the processor to rotate thereceived image to the determined orientation.
 9. The non-transitoryprogram storage device of claim 1, wherein the instructions to cause theprocessor to determine an orientation for the received image compriseinstructions to cause the processor to determine a difference between aknown typical position of the one or more identified features and aposition of the one or more identified features in the received image.10. The non-transitory program storage device of claim 1, wherein theinstructions to cause the processor to determine an orientation for thereceived image comprise instructions to cause the processor to determinea difference between a known typical alignment of the one or moreidentified features and an alignment of the one or more identifiedfeatures in the received image.
 11. The non-transitory program storagedevice of claim 1, wherein the instructions to cause the processor todetermine an orientation for the received image comprise instructions tocause the processor to utilize rotational information from an imagecapture device used to obtain the received image and an orientationdetermination for a previously analyzed image obtained by the imagecapture device.
 12. A device comprising: an image capture component; amemory; and a processor operatively coupled to the memory and the imagecapture component and configured to execute program code stored in thememory to receive an image obtained with the image capture component;analyze the received image to identify a detected feature; determine anorientation for the received image based, at least in part, on thedetected feature; determine an offset between a known typical alignmentand an identified alignment of the detected feature at the determinedorientation; rotate the image based, at least in part, on the determinedoffset to generate a straightened image; and save the straightened imagein the memory.
 13. The device of claim 12, wherein the detected featurecomprises one or more human faces.
 14. The device of claim 12, whereinthe detected feature comprises intensity gradient information in thereceived image.
 15. The device of claim 12, wherein the detected featureis identified based on a ranking of a plurality of available features.16. The device of claim 12, wherein the program code to cause theprocessor to determine an orientation for the received image comprisesprogram code to cause the processor to assign an orientation confidencevalue to the determined orientation.
 17. The device of claim 16, furthercomprising program code to cause the processor to rotate the receivedimage to the determined orientation.
 18. A method, comprising:receiving, by a processor, an image obtained with an image capturedevice; analyzing, by the processor, the received image with a featuredetector; determining, by the processor, a first image orientation forthe received image based, at least in part, on a detected alignment ofone or more features in the received image identified by the featuredetector; rotating the received image to the first image orientation;determining, by the processor, a second image orientation for thereceived image based, at least in part, on a difference between a knowntypical alignment and the first image orientation; rotating, by theprocessor, the received image based, at least in part, on the determinedsecond image orientation to generate a straightened image and saving thestraightened image in a memory.
 19. The method of claim 18, whereindetermining a second image orientation for the received image comprisesdetermining an in-plane rotational difference between a known typicalalignment and the first image orientation.
 20. The method of claim 18,wherein the feature detector comprises a feature detector configured toidentify human faces.